package web.listeners;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ValueChangeEvent;

import web.layout.NotificationCheckbox;
import web.layout.NotificationInput;

@ManagedBean
@ViewScoped
public class NotificationCheckboxListener {
	
	@ManagedProperty(value="#{notificationInput}")
	private NotificationInput notificationInput;
	
	@ManagedProperty(value="#{notificationCheckbox}")
	private NotificationCheckbox notificationCheckbox;
	
	public NotificationCheckboxListener(){}
	
	public NotificationInput getNotificationInput() {
		return notificationInput;
	}

	public void setNotificationInput(NotificationInput notificationInput) {
		this.notificationInput = notificationInput;
	}
	
	public NotificationCheckbox getNotificationCheckbox() {
		return notificationCheckbox;
	}

	public void setNotificationCheckbox(NotificationCheckbox notificationCheckbox) {
		this.notificationCheckbox = notificationCheckbox;
	}

	public void minTempCheckboxChanged(ValueChangeEvent event){
		if(notificationCheckbox.getMinTempCheckbox().isSelected()){
			notificationInput.getMinTempInput().setDisabled(false);
		}else{
			notificationInput.getMinTempInput().setDisabled(true);
		}
	}	
	
	public void maxTempCheckboxChanged(ValueChangeEvent event){
		if(notificationCheckbox.getMaxTempCheckbox().isSelected()){
			notificationInput.getMaxTempInput().setDisabled(false);
		}else{
			notificationInput.getMaxTempInput().setDisabled(true);
		}
	}
	
	public void minPressureCheckboxChanged(ValueChangeEvent event){
		if(notificationCheckbox.getMinPressureCheckbox().isSelected()){
			notificationInput.getMinPressureInput().setDisabled(false);
		}else{
			notificationInput.getMinPressureInput().setDisabled(true);
		}
	}	
	
	public void maxPressureCheckboxChanged(ValueChangeEvent event){
		if(notificationCheckbox.getMaxPressureCheckbox().isSelected()){
			notificationInput.getMaxPressureInput().setDisabled(false);
		}else{
			notificationInput.getMaxPressureInput().setDisabled(true);
		}
	}
}
